package com.tvunetworks.device.extra.controller;

import com.tvunetworks.center.common.model.CommandParam;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.device.extra.service.feign.RwsFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Ethan
 * @program:
 * @description:
 * @create: 2022/3/21 16:57
 **/
@RestController
@RequestMapping("receiver")
@Slf4j
public class ReceiverController {

    @Autowired
    private RwsFeignService rwsFeignService;
    /**
     * 和R命令交互
     * @param param categoryId 和 operationType 和data
     * @return String
     */
    @PostMapping("/command/{name}")
    public Result command(@RequestBody CommandParam param) {
        try {
            return rwsFeignService.command(param);
        } catch (Exception e) {
            log.error("====command exception====",e);
            return ResultUtil.exception();
        }
    }
}
